package work.base.data.stream;

import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author shenminglong@kedacom.com
 * @date 2022-01-27
 */
public class parallelStreamTest02 {

    public static void main(String[] args) {

        List<String> list = Stream.of("1","2","3","4").collect(Collectors.toList());
        list.parallelStream().forEach(k-> {

            List<String> list2 = Stream.of("1","2").collect(Collectors.toList());
            list2.parallelStream().forEach(m-> {
                try {
                    TimeUnit.SECONDS.sleep(5);
                    System.out.println(Thread.currentThread().getName());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
            try {
                TimeUnit.SECONDS.sleep(5);
                System.out.println(Thread.currentThread().getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        System.out.println("END");
        System.out.println(Thread.currentThread().getName() + "   == 主线程");
    }
}
